package com.ego.goods.controller;

import com.ego.goods.service.GoodsService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@Controller
public class GoodsWebController {

    @Resource
    private GoodsService goodsService;

    @GetMapping("/item/{id}.html")
    public String item(@PathVariable("id") Long id, Model model) {
        //1.查询数据库数据
        //加载数据
        Map<String, Object> modelMap = this.goodsService.loadModel(id);
        //2.生成静态页面
        //goodsService.createStaticHtml(modelMap,id);
        //把数据放入模型中
        model.addAllAttributes(modelMap);

        //3.响应视图
        return "item";
    }
}
